package czy;
public class Test
{
public static void main (String args[])
{
   
ComplexNumber a = new ComplexNumber(20,10);
ComplexNumber b = new ComplexNumber(5,5);
   double z = 10.0;
   
System.out.println(a.toString() + " + " +b.toString() + " = " + a.complexAdd(b).toString());
System.out.println(a.toString() + " + " + z + " = "  + a.complexAdd(z).toString());
   

System.out.println(a.toString() + " - " + b.toString() + " = " + a.complexMinus(b).toString());
System.out.println(a.toString() + " - " + z + " = " + a.complexMinus(z).toString());

System.out.println(a.toString() + " * " + b.toString() + " = " + a.complexMinus(b).toString());
System.out.println(a.toString() + " * " + z + " = " + a.complexMulti(z).toString());

}
}

class ComplexNumber
{
private double realpart;
private double imaginpart;
ComplexNumber()
{
	realpart = 0.0;
   imaginpart = 0.0;
}
ComplexNumber(double r,double I)
{
    realpart = r;
	imaginpart = I;
}
ComplexNumber(ComplexNumber c)
{
	realpart = c.getRealPart();
	imaginpart = c.getImaginaryPart();
}
double getRealPart()
{
   return realpart;
}
double getImaginaryPart()
{
   return  imaginpart;
}
void setRealPart(double d)
{
	realpart = d;
}
void setImaginaryPart(double d)
{
	imaginpart = d;
}
ComplexNumber complexAdd(ComplexNumber c)
{
   return new ComplexNumber( this.realpart + c.getRealPart(), this.imaginpart + c.getImaginaryPart());
}
ComplexNumber complexAdd(double c)
{
   return new ComplexNumber( this.realpart + c, this.imaginpart);
}

ComplexNumber complexMinus(ComplexNumber c)
{
   return new ComplexNumber( this.realpart - c.getRealPart(),this.imaginpart - c.getImaginaryPart());
}
ComplexNumber complexMinus(double c)
{
   return new ComplexNumber( this.realpart - c, this.imaginpart);
}

ComplexNumber complexMulti(ComplexNumber c)
{
   return new ComplexNumber( this.realpart * c.getRealPart()  - this.imaginpart * c.getImaginaryPart(),
   this.realpart * c.getImaginaryPart() + this.imaginpart * c.getRealPart());
}
ComplexNumber complexMulti(double c)
{
   return new ComplexNumber( this.realpart * c, this.imaginpart * c);
}

public String toString()
{
   return "(" + realpart + " + " + imaginpart + " i" + ")";
 }
}